package com.ofps.web.controller.forms;

import com.ofps.forms.common.utils.R;
import com.ofps.forms.domain.AnswerRadio;
import com.ofps.forms.service.AnswerRadioService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;


/**
 * @author pyn
 * @email ${email}
 * @date 2022-05-17 11:26:55
 */
@RestController
@RequestMapping("answerradio")
public class AnswerRadioController {
    @Autowired
    private AnswerRadioService answerRadioService;


    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("answerradio:save")
    public R save(HttpServletRequest request, @RequestBody AnswerRadio answerRadio) {
        return answerRadioService.save(request, answerRadio);
    }


    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("answerradio:delete")
    public R delete(@RequestBody Map<String, Object> body) {
        return answerRadioService.delete(body);
    }

    @RequestMapping("/summerize")
    @RequiresPermissions("answwerradio:summerize")
    public R summerize(@RequestBody Map<String, Object> body) {
        Map<String, Object> summerizeRatioMessages = new HashMap<String, Object>();
        summerizeRatioMessages = answerRadioService.summerizeRadioMessage(body);
        if (null == summerizeRatioMessages)
            return R.ok("暂无信息!");
        else
            return R.ok("查询成功!").put("summerize_datetime", summerizeRatioMessages);
    }
}
